#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 10;
typedef pair<int, int> ppi;
map<ppi, int> mp;
vector<int> e[N];

int w[N];
int n, m;

int fa[N], son[N], sz[N], top[N], dep[N];
void dfs1(int u, int father)
{
	fa[u] = father, sz[u] = 1, dep[u] = dep[father] + 1;
	for (auto s : e[u])
	{
		if (s == father)
			continue;
		dfs1(s, u);
		sz[u] += sz[s];
		if (sz[son[u]] < sz[s]) son[u] = s;
	}
}

void dfs2(int u, int t)
{
	top[u] = t;
	if (!son[u]) return;
	dfs2(son[u], t);
	
	for (auto s : e[u])
	{
		if (s == fa[u] || s == son[u])
			continue;
		dfs2(s, s);
	}
}

int cla(int u, int v)
{
	while (top[u] != top[v])
	{
		if (dep[top[u]] < dep[top[v]]) swap(u, v);
		u = fa[top[u]];
	}
	return dep[u] < dep[v] ? u : v;
}

void cal_sum(int u)
{
	for (auto s : e[u])
	{
		if (s == fa[u])
			continue;
		cal_sum(s);
		w[u] += w[s];
	}
}

void slove()
{
	cin >> n >> m;
	int x, y;
	for (int i = 0; i < n - 1; i++)
	{
		cin >> x >> y;
		e[x].push_back(y);
		e[y].push_back(x);
		mp[{x, y}] = mp[{y, x}] = i + 1;
	}
	
	dfs1(1, 0);
	dfs2(1, 1);
	
	//树上差分
	int a, b;
	for (int i = 0; i < m; i++)
	{
		cin >> a >> b;
		w[a]++; w[b]++;
		w[cla(a, b)] -= 2;	
	}
	//再做一次树上前缀和
	cal_sum(1);
	
	//遍历每个点
	int ret = 0;
	for (int i = 1; i <= n; i++)
	{
		if (w[i] == m)
		{
			ret = max(ret, mp[{i, fa[i]}]);
		}
	}
	cout << ret;
}

signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	slove();
	return 0;
}